package com.douziit.meilianoa.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.douziit.meilianoa.base.request.PageRequest;
import com.douziit.meilianoa.base.response.ResponseData;
import com.douziit.meilianoa.base.response.ResponseUtil;
import com.douziit.meilianoa.entity.ApprovalLog;
import com.douziit.meilianoa.service.ApprovalLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 审核日志 控制类
 */
@Slf4j
@RestController
@RequestMapping("/approvalLog")
public class ApprovalLogController {


    @Autowired
    private ApprovalLogService approvalLogService;


    /**
     * 添加审核日志
     */
    @PostMapping("/addApprovalLog")
    public ResponseData addApprovalLog(@RequestBody ApprovalLog approvalLog){
        approvalLogService.save(approvalLog);
        return ResponseUtil.jsonSuccess(0);
    }

    /**
     * 指定项目下审核日志列表
     */
    @PostMapping("/listApprovalLog")
    public ResponseData listApprovalLog(@RequestBody PageRequest req){
        List<ApprovalLog> list = approvalLogService.list(new QueryWrapper<ApprovalLog>().eq("project_id",req.getProjectId()));
        return ResponseUtil.jsonSuccess(list);
    }
}
